package de.idgard.android.addon.services;

import android.content.Context;
import de.idgard.android.addon.backend.IDGBackendService;
import de.idgard.android.addon.backend.impl.BackendServiceRegistry;
import de.idgard.android.addon.proxy.services.ProxyService;
import de.idgard.android.addon.proxy.services.impl.ProxyServiceRegistry;
import de.idgard.android.addon.ui.services.AddonStateService;
import de.idgard.android.addon.ui.services.BrowserPrivateModeService;
import de.idgard.android.addon.ui.services.BrowserTabService;
import de.idgard.android.addon.ui.services.BrowserUtilityService;
import de.idgard.android.addon.ui.services.JavaScriptLoaderService;
import de.idgard.android.addon.ui.services.LayoutAdjustmentService;
import de.idgard.android.addon.ui.services.NewsService;
import de.idgard.android.addon.ui.services.OrchestrationService;
import de.idgard.android.addon.ui.services.PreferenceService;
import de.idgard.android.addon.ui.services.PropertiesService;
import de.idgard.android.addon.ui.services.TransparencyStateService;
import de.idgard.android.addon.ui.services.UpdateService;
import de.idgard.android.addon.ui.services.WebIconService;
import de.idgard.android.addon.ui.services.ZircoToIDGardAPI;
import de.idgard.android.addon.ui.services.impl.UIServiceRegistry;
import de.idgard.webapp.user.client.service.LoginServiceRF.LoginService;

/**
 * 
 * @author ckaratza
 * 
 */

public final class GlobalServiceRegistry {

	private static GlobalServiceRegistry instance;

	private GlobalServiceRegistry() {

	}

	public static GlobalServiceRegistry instance() {
		if (instance == null) {
			instance = new GlobalServiceRegistry();
		}
		return instance;
	}

	public boolean isInit() {
		return init;
	}

	public void resetContext(Context ctx) {
		UIServiceRegistry.instance().resetContext(ctx);
		BackendServiceRegistry.instance().resetContext(ctx);
		ProxyServiceRegistry.instance().resetContext(ctx);
	}

	private boolean init = false;

	public void init(Context ctx) {
		if (init) {
			return;
		}
		ProxyServiceRegistry.instance().init(ctx);
		UIServiceRegistry.instance().init(ctx);

		BackendServiceRegistry.instance().init(ctx);

		init = true;
	}
	
	public UpdateService getUpdateService() {
		return UIServiceRegistry.instance().getUpdateService();
	}

	public ZircoToIDGardAPI getZircoToIDGardAPI() {
		return UIServiceRegistry.instance().getZircoToIDGardAPI();
	}

	public OrchestrationService getOrchestrationService() {
		return UIServiceRegistry.instance().getOrchestrationService();
	}

	public ProxyService getProxyService() {
		return ProxyServiceRegistry.instance().getProxyService();
	}

	public PropertiesService getPropertiesService() {
		return UIServiceRegistry.instance().getPropertiesService();
	}

	public AddonStateService getAddonStateService() {
		return UIServiceRegistry.instance().getAddonStateService();
	}

	public BrowserUtilityService getBrowserUtilityService() {
		return UIServiceRegistry.instance().getBrowserUtilityService();
	}

	public BrowserPrivateModeService getBrowserPrivateModeService() {
		return UIServiceRegistry.instance().getBrowserPrivateModeService();
	}

	public PreferenceService getPreferenceService() {
		return UIServiceRegistry.instance().getPreferenceService();
	}

	public BrowserTabService getBrowserTabService() {
		return UIServiceRegistry.instance().getBrowserTabService();
	}

	public TransparencyStateService getTransparencyStateService() {
		return UIServiceRegistry.instance().getTransparencyStateService();
	}

	public IDGBackendService getBackendService() {
		return BackendServiceRegistry.instance().getBackendService();
	}

	public LoginService getLoginService() {
		return BackendServiceRegistry.instance().getLoginService();
	}

	public WebIconService getWebIconService() {
		return UIServiceRegistry.instance().getWebIconService();
	}

	public NewsService getNewsService() {
		return UIServiceRegistry.instance().getNewsService();
	}

	public LayoutAdjustmentService getLayoutAdjustmentService() {
		return UIServiceRegistry.instance().getlayouAdjustmentService();
	}

	public JavaScriptLoaderService getJavaScriptLoaderService() {
		return UIServiceRegistry.instance().getJavaScriptLoaderService();
	}

}
